package ms.maplestory.boot.enums;

import java.util.Arrays;

/**
 * 背包类型
 */
public enum InventoryType {

    Equipped(-1),
    Equip(1),
    Use(2),
    Setup(3),
    Etc(4),
    Cash(5);

    private byte value;

    InventoryType(int value) {
        this.value = (byte) value;
    }

    public byte getValue() {
        return value;
    }

    public static InventoryType getTypeByVal(int val) {
        return Arrays.stream(InventoryType.values()).filter(t -> t.getValue() == val).findFirst().orElse(null);
    }

    public static InventoryType getTypeByString(String subMap) {
        subMap = subMap.toLowerCase();
        InventoryType res = null;
        switch (subMap) {
            case "cash":
            case "pet":
                res = Cash;
                break;
            case "consume":
            case "special":
            case "use":
                res = Use;
                break;
            case "etc":
                res = Etc;
                break;
            case "install":
            case "setup":
                res = Setup;
                break;
            case "eqp":
            case "equip":
                res = Equip;
                break;
        }
        return res;
    }

    public boolean isStackable() {
        return this != Equip && this != Equipped && this != Cash;
    }

}
